package com.bothin.experiment4.service.impl;

import com.bothin.experiment4.dao.ContactMapper;
import com.bothin.experiment4.dao.CustomerMapper;
import com.bothin.experiment4.dao.EmployeeMapper;
import com.bothin.experiment4.dao.ProductMapper;
import com.bothin.experiment4.dto.StatisticDTO;
import com.bothin.experiment4.dto.SumaryDTO;
import com.bothin.experiment4.service.IStatisticService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by bothin
 * At 2019/12/21 17:01
 * Description:
 */
@Service
public class StatisticServiceImpl implements IStatisticService {
    @Autowired
    private ContactMapper contactMapper;
    @Autowired
    private CustomerMapper customerMapper;
    @Autowired
    private EmployeeMapper employeeMapper;
    @Autowired
    private ProductMapper productMapper;

    /**
     * 获取一段时间内公司的销售额
     * @param start
     * @param end
     * @return
     */
    @Override
    public SumaryDTO getTheSumAPeriodOfTime(String start, String end) {
        return new SumaryDTO(start+"~"+end+"公司的销售额",contactMapper.getTheSumAPeriodOfTime(start,end));
    }

    /**
     * 按年统计公司的销售额
     * @return
     */
    @Override
    public List<SumaryDTO> getTheSumEachYearOfCompany() {
        return contactMapper.getTheSumEachYear();
    }

    /**
     * 统计某年每个月公司的销售额
     * @param year
     * @return
     */
    @Override
    public List<SumaryDTO> getTheSumEachMouthOfCompany(String year) {
        return contactMapper.getTheSumEachMouth(year);
    }

    /**
     * 统计某年每个周公司的销售额
     * @param year
     * @return
     */
    @Override
    public List<SumaryDTO> getTheSumEachWeekOfCompany(String year) {
        return contactMapper.getTheSumEachWeek(year);
    }

    @Override
    public List<StatisticDTO> getAllCustomerStatistic(String start, String end, int limit) {
        return customerMapper.getAllCustomerStatistic1(start,end,limit);
    }

    @Override
    public List<StatisticDTO> getAllCustomerStatistic(int limit) {
        return customerMapper.getAllCustomerStatistic2(limit);
    }

    @Override
    public List<StatisticDTO> getAllCustomerStatistic() {
        return customerMapper.getAllCustomerStatistic3();
    }

    @Override
    public List<StatisticDTO> getAllSalesmanSStatistic(String start, String end, int limit) {
        return employeeMapper.getAllSalesmanSStatistic1(start,end,limit);
    }

    @Override
    public List<StatisticDTO> getAllSalesmanSStatistic(int limit) {
        return employeeMapper.getAllSalesmanSStatistic2(limit);
    }

    @Override
    public List<StatisticDTO> getAllSalesmanSStatistic() {
        return employeeMapper.getAllSalesmanSStatistic3();
    }

    @Override
    public SumaryDTO getOneSalesmanSStatisticById(String start, String end, int id) {
        return employeeMapper.getOneSalesmanSStatisticById1(start,end,id);
    }

    @Override
    public SumaryDTO getOneSalesmanSStatisticById(int id) {
        return employeeMapper.getOneSalesmanSStatisticById2(id);
    }

    /**
     * 返回销售人员每年的销售业绩
     * @param id
     * @return
     */
    @Override
    public List<SumaryDTO> getTheSumEachYearOfSalesman(int id) {
        return employeeMapper.getTheSumEachYear(id);
    }
    /**
     * 查询某员工每月业绩
     * @param id
     * @return
     */
    @Override
    public List<SumaryDTO> getTheSumEachMouthOfSalesman(String year, int id) {
        return employeeMapper.getTheSumEachMouth(year,id);
    }

    @Override
    public List<StatisticDTO> getAllProductSStatistic(String start, String end, int limit) {
        return productMapper.getAllProductSStatistic1(start,end,limit);
    }

    @Override
    public List<StatisticDTO> getAllProductSStatistic(int limit) {
        return productMapper.getAllProductSStatistic2(limit);
    }

    @Override
    public List<StatisticDTO> getAllProductSStatistic() {
        return productMapper.getAllProductSStatistic3();
    }
}
